<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

 <%
	 String soPin= request.getSession().getAttribute("soPin").toString();
	 String userPin= request.getSession().getAttribute("userPin").toString();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<script type="text/javascript">
		function unlock(userPin,soPin)
		{
			var usbKeyObj;
			var clientComObj;
			var ret = false;
			var device;  
			var ETAX_SUCCESS = 0;
			try
			{
				// 1. connect
				usbKeyObj=new ActiveXObject("NetcaEtaxCOM.USBKeyObject");
				clientComObj = new ActiveXObject("NetcaBpmsClientCom.PKI");
				
				ret = usbKeyObj.UKeyConnect(0);
				if(ret!=ETAX_SUCCESS) 
				{
					alert("连接USBKey失败");
					return false;
				}
				
				// unlockPin
				ret = usbKeyObj.USBKeyUnlockPin(userPin, soPin);
				usbKeyObj.UKeyDisConnect();
				if(ret!=ETAX_SUCCESS) 
				{
					alert("解锁失败");
					return false;
				}
				else
				{
					alert("解锁成功");
					// vetifyPin
					clientComObj.Connect();
					ret = false;
					ret = clientComObj.VerifyPIN(userPin);
					// alert(ret);
					if(!ret) 
					{
						return false;
					}
				}
				return true;
			}
			catch (e)
			{
				alert(e.message);
				return false;
			}
		}

	</script>
<title>Insert title here</title>
</head>
	<body onload="unlock('<%=userPin %>','<%=soPin%>')">
	 
	</body>
</html>